# -*- coding: utf-8 -*-

import logging

from dao.MysqlDao import insert_sql
from dao.MysqlDao import search_sql

logging.basicConfig(level=logging.INFO, format='%(levelname)s %(message)s', datefmt='[%Y%m%d-%H:%M:%S]')


def insert_month_recommend(movie_list):
    sql_format = '''
    REPLACE INTO month_recommend(title, content, created_time) 
    VALUES (%s,%s,%s);'''
    insert_sql(sql_format, movie_list)


def get_month_recommend(movie_id):
    sql_format = f''' 
    select id, title, content, created_time
    from month_recommend   
    where id = {movie_id}'''
    result = search_sql(sql_format)
    return result


def get_month_recommend_list():
    sql_format = f''' 
    select id, title, content, created_time
    from month_recommend  order by id desc 
    limit 10 '''
    result = search_sql(sql_format)
    return result
